package com.ssy.lingxi.common.constant.marketing;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 所属类型
 * @author yzc
 * @version 2.0.0
 * @date 2021/8/13
 */
public enum BelongTypeEnum {

    /**
     * 平台 - 1
     */
    PLATFORM(1, "平台"),

    /**
     * 商家 - 2
     */
    MERCHANT(2, "商家");


    private final Integer code;
    private final String message;

    BelongTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getCodeMessage(Integer code) {
        BelongTypeEnum status = Arrays.stream(BelongTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return status == null ? "未知" : status.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public static BelongTypeEnum parse(Integer code) {
        return Arrays.stream(BelongTypeEnum.values()).filter(v -> v.getCode().equals(code)).findFirst().orElse(null);
    }

}